package edu.hawaii.webspider;

import static org.junit.Assert.fail;
import org.junit.Test;

/**
 * Tests the functionality of WebSpider.
 * 
 * @author Andrew Wong
 *
 */
public class TestWebSpider {
  static final String googleUrl = "http://www.google.com";
  static final String hackystatUrl = "http://www.hackystat.org";
  static final String uhUrl = "http://www.hawaii.edu";
  
  /**
   *  Tests the main function of WebSpiderExample.
   * @throws Exception Thrown if a web page fails to parse.
   */
  @Test
  public void testTotalLinks() throws Exception {
    String test1[] = new String[4];
    
    test1[0] = "-totallinks";
    test1[1] = hackystatUrl;
    test1[2] = "20";
    test1[3] = "-logging";
    
    try {
      WebSpider.main(test1);
    }
    catch (Exception e) {
      fail("Webspider execution failed.");
    }
  }

  /**
   *  Tests the main function of WebSpiderExample.
   * @throws Exception  Thrown if a web page fails to parse. 
   */
  @Test
  public void testMostPopular() throws Exception {
    String test2[] = new String[4];
    
    test2[0] = "-mostpopular";
    test2[1] = "http://www.google.com";
    test2[2] = "20";
    test2[3] = "-logging";

    try {    
      WebSpider.main(test2);
    }
    catch (Exception e) {
      fail("Webspider execution failed.");
    }

  }

}
